#include <pthread.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <spawn.h>
#include <wait.h>
#include <linux/types.h>

int main()
{
	int sock;
	struct sockaddr_in serv_addr;
	char message[30];
	int str_len;

	
	sock = socket(AF_INET, SOCK_STREAM, 0);
	if(sock == -1)
		printf("socket() error");

	memset(&serv_addr, 0, sizeof(serv_addr));
	serv_addr.sin_family=AF_INET;
	serv_addr.sin_addr.s_addr = inet_addr("192.168.6.128");
	serv_addr.sin_port = htons(atoi("9999"));

	if(connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) == -1)
		printf("connect() error!");
    char *sendData = "hello, I am clint!\n";
    send(sock, sendData, strlen(sendData), 0);
	str_len = read(sock, message, sizeof(message) - 1);
	if(str_len == -1)
		printf("read() error!");

	printf("Message from server: %s \n", message);
	close(sock);
	return 0;
}	
